subroutine r1ai_t2aeim_fme(r1, t2, fme, & 
               icore, fact)
!
use mod_size
use mod_iop
use mod_orbit
use mod_ioff 
implicit none
!
real*8, intent(in) :: fact
real*4, intent(in) :: r1(*)
real*4, intent(in) :: fme(*) 
!
real*4, intent(inout) :: t2(*),icore(*)
!
integer :: i, j, a, b, nsize
integer :: i0, i1, i2, i3
real*8, external :: dnrm2
i0 = 1
i1 = i0 + nvvoo*isd
i2 = i1 + nvvoo*isd
!this is to do r1(ai) = r1(ai) +t2(ae,im)*f(me)
!====AA
! t2(AE,IM)*F(ME) + t2(Ae,Im)*F(me) 
call iexpso(t2(ioi3(1)), icore(i0), vrta, vrta, 0, 1, popa, popa, 0, 0, 1)
call iexpso(icore(i0), icore(i1), vrta, vrta, 1, 0, popa, popa, 0, 1, 1)
call sstgenso(icore(i1), icore(i0), nsize, vrta, vrta, popa, popa, &
              icore, 1, '1324')
call VpqmnVmnrs_to_Vpqrs(icore(i0), fme(ifvo(1)), 1, 1, vrta, popa, 1, &
             vrta, popa, 1, zorb, zorb, 1, r1(ifvo(1)), 1, fact, 1.d0)
!
call sstgenso(t2(ioi3(2)), icore(i0), nsize, vrta, vrtb, popa, popb, & 
              icore, 1, '1324') 
call VpqmnVmnrs_to_Vpqrs(icore(i0), fme(ifvo(2)), 1, 1, vrtb, popb, 1, &
             vrta, popa, 1, zorb, zorb, 1, r1(ifvo(1)), 1, fact, 1.d0)
!====BB
! t2(ae,im)*fme + t2(aE,iM)*F(ME)
call iexpso(t2(ioi3(3)), icore(i0), vrtb, vrtb, 0, 1, popb, popb, 0, 0, 1)
call iexpso(icore(i0), icore(i1), vrtb, vrtb, 1, 0, popb, popb, 0, 1, 1)
call sstgenso(icore(i1), icore(i0), nsize, vrtb, vrtb, popb, popb, &
              icore, 1, '1324')
call VpqmnVmnrs_to_Vpqrs(icore(i0), fme(ifvo(2)), 1, 1, vrtb, popb, 1, &
             vrtb, popb, 1, zorb, zorb, 1, r1(ifvo(2)), 1, fact, 1.d0)
!
call sstgenso(t2(ioi3(2)), icore(i0), nsize, vrta, vrtb, popa, popb, & 
              icore, 1, '1324') 
call VmnpqVmnrs_to_Vpqrs(icore(i0), fme(ifvo(1)), 1, 1, vrta, popa, 1, &
             vrtb, popb, 1, zorb, zorb, 1, r1(ifvo(2)), 1, fact, 1.d0)
!
return
end
